﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_LayoutIndex.cshtml";
}
<link href="~/Content/styles/BillDetail.css?v=1.3" rel="stylesheet" />
<script src="~/Content/scripts/jquery/ajaxfileupload.js"></script>
<script>
    var keyValue = request('keyValue');
    var State = "", State1 = "", State2 = "", State3 = "", Id = "", BillState = 1;
    var BillState = 1, ApprovalState = 0;
    var _organizeid = "@LeSoft.Application.Code.OperatorProvider.Provider.Current().CompanyId";
    var hashTable = new Object();
    var IsCheck = "F";
    var Code = "";
    var MarryInfo = "", IsPermant = 1;
    $(function () {
        InitialPage();
        InitControl();
        GetGrid1();
    });
    //初始化数据
    function InitControl() {
        if (!!keyValue) {
            $.SetForm({
                url: "../../QualificationManage/Retrial/GetBillInfo",
                param: { keyValue: keyValue },
                success: function (data) {
                    Id = data.BillInfo.Id;
                    $("#Code").html(data.BillInfo.Code);
                    $(".AuditTimes").removeAttr("hidden");
                    $("#Times").text(data.BillInfo.ReCheckDay + "天")
                    if (data.BillInfo.CityBurceauCode != null) {
                        $("#SJBH").text("材料审核【市局受理编号：" + data.BillInfo.CityBurceauCode + "】")
                    }
                    else {
                        $("#CityBurceauCode").removeAttr("readonly");
                    }
                    if (data.BillInfo.State == 4) {
                        $("#AuditState_CL").removeAttr("hidden");
                        $("#AuditState_SJ").attr("hidden", "hidden");
                        $("#AuditState_SLZX").attr("hidden", "hidden");
                    }
                    $("#CityBurceauCode").val(data.BillInfo.CityBurceauCode);
                    $("#Category").text(GetCategory(data.BillInfo.Category));
                    Id = data.BillInfo.Id;
                    $("#State").text(GetState(data.BillInfo.State));
                    $("#SubmitCount").text(data.BillInfo.SubmitCount);
                    $("#BillInfo").SetWebControls(data.BillInfo);
                    $("#Name").text(data.MemberInfo.Name);
                    $("#Phone").text(data.MemberInfo.Phone);
                    $("#IDCard").text(data.MemberInfo.IDCard);
                    $("#SQRXX").SetWebControls(data.MemberInfo);
                    MarryInfo = data.MemberInfo.MarryInfo;
                    if (data.MemberInfo.HasLiveCard == "1" || data.MemberInfo.HasLiveCard == 1) {
                        IsPermant = 0;
                    }
                    GetGrid1();
                    GetGrid2(data.CheckRecordList);
                    GetGridB(data.CheckRecordList);
                    GetGridC(data.CheckRecordList);
                    GetGridD(data.CheckRecordList);
                    State = data.BillInfo.State;
                    $("#State").text(GetS(data.CheckRecordList));
                    var SignType = "";
                    switch (data.BillInfo.SignType) {
                        //   1- 单位 2-个人
                        case 1:
                        case "1": SignType = "单位";
                            break;
                        case 2:
                        case "2": SignType = "个人";
                            break;
                        default:
                    }
                    $("#SignType").text(SignType);
                    var FamilyType = "";
                    switch (data.BillInfo.FamilyType) {
                        case 1: FamilyType = "单身";
                            break;
                        case 2: FamilyType = "大龄青年";
                            break;
                        case 3: FamilyType = "家庭";
                            break;
                        default:
                    }
                    $("#FamilyType").text(FamilyType);
                }
            })
        }
    }

    //初始化页面
    function InitialPage() {
        //layout布局
        $('#layout').layout({
            applyDemoStyles: true,
            onresize: function () {
                $(window).resize()
            }
        });
        $('.profile-content').height($(window).height() - 20);
        $('.profile-nav').height($(window).height() - 20);


    }
    //侧面切换显示/隐藏
    function profileSwitch(id) {
        if (id == "BillContent") {
            $("#TrialRecord").hide();
            $("#TrialLog").hide();
            $("#BillContent").show();
        } else if (id == "TrialLog") {
            $("#TrialRecord").hide();
            $("#BillContent").hide();
            $("#TrialLog").show();
            getOperateGrid();
        }
        else {
            $("#BillContent").hide();
            $("#TrialLog").hide();
            $("#TrialRecord").show();

        }
    };


    //资料收集
    function GetGrid1() {
        debugger;
        var selectedRowIndex = 0;
        var $gridTable = $('#gridTable1');
        $gridTable.jqGrid({
            url: "../../QualificationManage/Retrial/GetMaterialList?keyValue=" + Id + "&MarryInfo=" + MarryInfo + "&HasLiveCard=" + IsPermant,
            postData: { "keyValue": keyValue },
            datatype: "json",
            autowidth: true,
            colModel: [
                { label: "主键", name: "Code", hidden: true },
                { label: "资料编号", name: "RuleCode", hidden: true },
                { label: "资料名称", name: "Name", index: "Name", width: 80, align: "left", sortable: false },
                {
                    label: "必须提交", name: "IsSubmit", index: "IsSubmit", width: 80, align: "left", sortable: false,
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue == 1)
                            return "<span style='color: #b91a1a;'>是</span>";
                        else
                            return "<span style='color: #cecece;'>否</span>";
                    }
                },
                 {
                     label: "必须上传", name: "IsUpload", index: "IsUpload", width: 80, align: "left", sortable: false,
                     formatter: function (cellvalue, options, rowObject) {
                         if (cellvalue == 1)
                             return "<span style='color: #b91a1a;'>是</span>";
                         else
                             return "<span style='color: #5cb85c;'>否</span>";
                     }
                 },
                  {
                      label: "是否提交", name: "CommitState", index: "CommitState", width: 80, align: "left", sortable: false,
                      formatter: function (cellvalue, options, rowObject) {
                          if (cellvalue == 1) return "<i class='fa fa-toggle-on  fa-2x' style='margin-left:10px;'><i/>";
                          else return "<i class='fa fa-toggle-off  fa-2x' style='margin-left:10px;'><i/>";

                      }
                  },
                {
                    label: "是否上传", name: "UploadState", index: "UploadState", width: 80, align: "left", sortable: false,
                    formatter: function (cellvalue, options, rowObject) {

                        if (IsCheck == "F") return " <i class='fa fa-check fa-2x' style='margin-left:10px;'>";
                        return " <i class='fa fa-upload fa-2x' style='margin-left:10px;'><input class=\"fileImage\" id=\"fileImage_" + options.rowId + "_" + options.pos + "\"type=\"file\"  name=\"fileselect[]\"  style=\"position: absolute; width: 80px; height: 28px;opacity: 0; margin-top: -20px;  margin-left: -10px;\" onchange=\"UploadFile(" + options.rowId + "," + options.pos + ")\" /> ";

                    }
                },
                { label: "文件名", name: "FileName", index: "FileName", width: 100, align: "left", sortable: false },
                { label: "资料路径", name: "FileUrl", hidden: true },
                { label: "提交人", name: "CreateUserName", index: "CreateUserName", width: 80, align: "left", sortable: false },
                { label: "提交人ID", name: "CreateUserId", hidden: true },
                { label: "提交时间", name: "CreateDate", index: "CreateDate", width: 80, align: "left", sortable: false },
                { label: "接收人", name: "ReceiveUserName", index: "ReceiveUserName", width: 80, align: "center", sortable: false },
                { label: "接收时间", name: "ReceiveDate", index: "ReceiveDate", width: 80, align: "left", sortable: false },
                {
                    label: "是否合格", name: "IsQualified", index: "IsQualified", width: 100, align: "left", sortable: false,
                    formatter: function (cellvalue, options, rowObject) {
                        switch (cellvalue) {
                            case 1: return "<i class='fa fa-check fa-2x' style='color:green;margin-left:10px;'><i/>"; break;
                            default: return ""; break;
                        }
                    }
                },
                { label: "说明", name: "Description", index: "Description", width: 80, align: "left", sortable: false }
            ],
            viewrecords: true,
            rowNum: 30,
            rowList: [30, 50, 100],
            rownumbers: true,
            shrinkToFit: false,
            gridview: true,
            hidegrid: false,
            onSelectRow: function () {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function () {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            }, ondblClickRow: function () {
                var keyValue = $("#gridTable1").jqGridRowValue("FileUrl");
                if (keyValue != "") {
                    window.open(keyValue, "_blank", "width=1000, height=800,status=0");
                }

            },
            onCellSelect: function (rowid, iCol, cellcontent, e) {
                var QuaSaveMaterial = "@LeSoft.Application.Bussiness.WorkRoleSettingBLL.GetIsAudit(Convert.ToInt32(LeSoft.Application.Code.WorkRoleEnum.QuaSaveMaterial))";
                if (QuaSaveMaterial == "False") {
                    dialogMsg('您不是该业务的处理人！', 0);
                    return false;
                }
                if (iCol == 6 && BillState == 1) {

                    //提交资料
                    var sss = $gridTable.getCell(rowid, 5);
                    var s = $gridTable.getCell(rowid, 7);
                    debugger;
                    if (e.target.className == 'fa fa-toggle-off  fa-2x' && IsCheck == "T") {
                        $gridTable.setCell(rowid, iCol, "1");
                        $gridTable.setCell(rowid, 10, "@LeSoft.Application.Code.OperatorProvider.Provider.Current().UserName");
                        $gridTable.setCell(rowid, 11, "@LeSoft.Application.Code.OperatorProvider.Provider.Current().UserId");
                        $gridTable.setCell(rowid, 12, "@DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")");
                    }
                    else {
                        if (IsCheck == "T") {
                            $gridTable.setCell(rowid, iCol, "0");
                            $gridTable.setCell(rowid, 10, null);
                            $gridTable.setCell(rowid, 11, null);
                            $gridTable.setCell(rowid, 12, null);
                        }

                    }
                }
            }
        })

    }


    function UploadFile(rowid, iCol) {


        var rowData = $("#gridTable1").jqGrid('getRowData', rowid);
        var files = document.getElementById('fileImage_' + rowid + '_' + iCol).files;
        debugger;
        if (files.length > 0 && rowData != null) {
            $.ajaxFileUpload({
                url: "../../QualificationManage/Retrial/UploadFile",
                secureuri: false,
                fileElementId: 'fileImage_' + rowid + '_' + iCol,
                data: { keyValue: rowData.RuleCode },
                success: function (data, status) {
                    debugger;
                    var resObj = JSON.parse(data.body.innerText);
                    var ss = resObj.resultdata.split(',');
                    hashTable[ss[0]] = ss[1];
                    $('#gridTable1').setCell(rowid, 8, files[0].name);
                    $('#gridTable1').setCell(rowid, 9, ss[1]);
                    $('#gridTable1').setCell(rowid, 7, 1);
                },
                error: function (data, status, e) {
                    alert(e);
                }
            });

        }
    }

    //审核记录
    function GetGrid2(data) {
        var selectedRowIndex = 0;
        $gridTable = $("#gridTable2");

        $gridTable.jqGrid({
            datatype: "json",
            height: $(window).height() - 141,
            autowidth: true,
            colModel: [
                  { label: "主键", name: "Id", hidden: true },
                  {
                      label: "操作类别", name: "Type", index: "Type", width: 200, align: "center", sortable: false,
                      formatter: function (cellvalue) {
                          switch (cellvalue) {
                              case 1:
                              case "1":
                                  return "初审";
                              case 2:
                              case "3":
                                  return "材料提交";
                              case 3:
                              case "3":
                                  return "市局审批";
                              case 4:
                              case "4":
                                  return "复审";
                              default:

                          }
                      }
                  },
                  { label: "审核人", name: "CheckMan", index: "CheckMan", width: 200, align: "center", sortable: false },
                  { label: "审核时间", name: "CheckDate", index: "CheckDate", width: 200, align: "center", sortable: false },
                  {
                      label: "审核结果", name: "CheckFlag", index: "CheckFlag", width: 300, align: "center", sortable: false,
                      formatter: function (cellvalue, options, rowObject) {
                          var Msg = "<span  class='label' style='background-color:";
                          if (rowObject.Type == 1) {
                              if (cellvalue == 0) {
                                  Msg += "#B05B5C'>" + "初审未通过"
                              }
                              else {
                                  Msg += "#BCD186'>" + "初审通过"
                              }
                          }
                          if (rowObject.Type == 2) {
                              if (cellvalue == 0) {
                                  Msg += "#839B27'>" + "材料未通过"
                              }
                              else {
                                  Msg += "#81B981'>" + "材料通过"
                              }
                          }
                          if (rowObject.Type == 3) {
                              if (cellvalue == 0) {
                                  Msg += "#F09005'>" + "市局审批未通过"
                              }
                              else {
                                  Msg += "#5CB85C'>" + "市局审批通过"
                              }
                          }
                          if (rowObject.Type == 4) {
                              if (cellvalue == 0) {
                                  Msg += "#f00'>" + "复审未通过"
                              }
                              else {
                                  Msg += "#5CB85C'>" + "复审通过"

                              }
                          }
                          Msg += "</span>";
                          return Msg;
                      }
                  },
                  { label: "审核说明", name: "CheckMemo", index: "CheckMemo", width: 650, align: "center", sortable: false },
            ],
            viewrecords: true,
            rowNum: 300,
            sortname: 'CheckDate',
            sortorder: 'asc',
            rownumbers: true,
            gridview: true,
            onSelectRow: function (status) {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function () {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            }
        });
        $gridTable[0].addJSONData(data);

    }
    //操作记录
    function getOperateGrid() {
        $gridTable = $("#gridTable6");
        $gridTable.jqGrid({
            url: "../../SystemManage/Setting/GetOperateRecordList",
            postData: { BillId: Id },
            datatype: "json",
            height: $(window).height() - 141,
            autowidth: true,
            colModel: [
               { label: '项目主键', name: 'Id', hidden: true },
                        { label: '业务类别', name: 'Type', width: 100, align: 'center', sortable: false },
                        { label: '操作人', name: 'FromOperateName', width: 100, align: 'center', sortable: false },
                        { label: '操作时间', name: 'Date', width: 170, align: 'center', sortable: false },
                        {
                            label: "操作内容", name: "Content", index: "Content", width: 590, align: "left", sortable: false,
                            formatter: function (cellvalue, options, rowObject) {
                                if (!!rowObject.ToOperateName)
                                    return "发起者：" + rowObject.FromOperateName + "，接受者：" + rowObject.ToOperateName + "<br/>" + cellvalue;
                                else
                                    return "发起者：" + rowObject.FromOperateName + "<br/>" + cellvalue;
                            }
                        },
            ],
            viewrecords: true,
            rowNum: 300,
            rownumbers: true,
            gridview: true,

        });
    }

    //初审信息
    function Detail() {
        var Code = keyValue;
        top.tablist.newTab({
            id: "TrialForm",
            title: '初审详情【' + Code + '】',
            closed: true,
            icon: "fa fa-eye",
            url: top.contentPath + '/QualificationManage/FirstTrial/Form?keyValue=' + keyValue
        });
    }
    //提交
    function Submit(s) {
        var Memo = "";
        var Type = 0;
        var State = 1;
        var QuaCheckSecurity = "@LeSoft.Application.Bussiness.WorkRoleSettingBLL.GetIsAudit(Convert.ToInt32(LeSoft.Application.Code.WorkRoleEnum.QuaCheckSecurity))";
        var QuaCheckCenter = "@LeSoft.Application.Bussiness.WorkRoleSettingBLL.GetIsAudit(Convert.ToInt32(LeSoft.Application.Code.WorkRoleEnum.QuaCheckCenter))";
        switch (s) {
            case 1: Type = 2;

                if (QuaCheckSecurity == "False") {
                    dialogMsg('您不是该业务的处理人！', 0);
                    return false;
                }
                break;
            case 2:
                if (QuaCheckSecurity == "False") {
                    dialogMsg('您不是该业务的处理人！', 0);
                    return false;
                }
                if ($("#SJ_Memo").val() === "") {
                    dialogMsg('请说明不同意原因！', 0);
                    return false;
                }
                Memo = $("#SJ_Memo").val();
                Type = 2;
                State = "0";
                break;
            case 3: Type = 3;
                if (QuaCheckCenter == "False") {
                    dialogMsg('您不是该业务的处理人！', 0);
                    return false;
                }
                break;
            case 4:
                if (QuaCheckCenter == "False") {
                    dialogMsg('您不是该业务的处理人！', 0);
                    return false;
                }
                if ($("#SLZX_Memo").val() === "") {
                    dialogMsg('请说明不同意原因！', 0);
                    return false;
                }
                Type = 3;
                Memo = $("#SLZX_Memo").val();
                State = "0";
                break;
            default:
                break;
        }
        $.ConfirmAjax({
            msg: "注：您确认要进行此操作吗？",
            url: "../../QualificationManage/Retrial/SubmitForm",
            param: { keyValue: Id, Type: Type, State: State, Memo: Memo },
            loading: "正在保存数据...",
            success: function () {
                location.reload();
            }
        });

    }

    //材料审核
    function SubmitFile(s) {
        var QuaCheckMaterial = "@LeSoft.Application.Bussiness.WorkRoleSettingBLL.GetIsAudit(Convert.ToInt32(LeSoft.Application.Code.WorkRoleEnum.QuaCheckMaterial))";
        if (QuaCheckMaterial == "False") {
            dialogMsg('您不是该业务的处理人！', 0);
            return false;
        }
        if (s == 0) {
            if ($("#CL_Memo").val() == "") {
                dialogMsg('请说明不通过原因！', 0);
                return false;
            };
        }
        if (s == 1) {
            if ($("#CityBurceauCode").val() === "") {
                dialogMsg("请输入市局受理编号！", 0);
                return false;
            }
            if ($("#CityBurceauCode").val().length != 15) {

                dialogMsg("市局受理编号不合法，长度应为15位！", 0);
                return false;
            }
        }
        var Data = [];
        var obj = $("#gridTable1").jqGrid("getRowData");
        var scount = 0, ucount = 0;
        for (var i = 0; i < obj.length; i++) {
            obj[i].BillCode = keyValue;
            obj[i].IsSubmit = obj[i].IsSubmit.indexOf("是") > 0 ? 1 : 0;
            obj[i].IsUpload = obj[i].IsUpload.indexOf("是") > 0 ? 1 : 0;
            obj[i].UploadState = obj[i].UploadState.indexOf("check") > 0 ? 1 : 0;
            obj[i].CommitState = obj[i].CommitState.indexOf("on") > 0 ? 1 : 0;
            if (obj[i].IsSubmit == 1 && obj[i].CreateDate == "") scount++;
            if (obj[i].IsUpload == 1 && obj[i].FileUrl == "") ucount++;
            debugger;
            if (s == 1) {
                if (obj[i].IsSubmit == 1 && obj[i].CommitState == 0) {

                    dialogMsg(obj[i].Name + "必须提交，才能审核", 0);
                    return false;
                }
                //if (obj[i].IsUpload == 1 && obj[i].UploadState == 0) {
                //    dialogMsg(obj[i].Name + "必须上传，才能审核", 0);
                //    return false;
                //}
                if (obj[i].IsUpload == 1 && obj[i].CommitState == 0) {
                    dialogMsg(obj[i].Name + "必须提交，才能审核", 0);
                    return false;
                }
            }

        }
        var Memo = $("#CL_Memo").val();
        $.ConfirmAjax({
            msg: "注：您确认要进行此操作吗？",
            url: "../../QualificationManage/Retrial/SumbitFile",
            param: { keyValue: Id, State: s, Memo: Memo, CityBurceauCode: $("#CityBurceauCode").val(), lst: JSON.stringify(obj) },
            loading: "正在保存数据...",
            success: function () {
                location.reload();
            }
        });
    }
    //保存材料
    function SaveMater() {
        var QuaSaveMaterial = "@LeSoft.Application.Bussiness.WorkRoleSettingBLL.GetIsAudit(Convert.ToInt32(LeSoft.Application.Code.WorkRoleEnum.QuaSaveMaterial))";
        if (QuaSaveMaterial == true) {
            dialogMsg('您不是该业务的处理人！', 0);
            return false;
        }
        if (!$('#CLTJ').Validform()) {
            return false;
        }
        if (!$('#SJSP').Validform()) {
            return false;
        }
        if (!$('#SLZXSP').Validform()) {
            return false;
        }
        var Data = [];
        var obj = $("#gridTable1").jqGrid("getRowData");
        var scount = 0, ucount = 0;
        if (obj.length <= 0) {
            dialogMsg("至少需要一条数据，才能保存！", 0);
            return false;
        }
        for (var i = 0; i < obj.length; i++) {

            obj[i].BillCode = keyValue;
            obj[i].IsSubmit = obj[i].IsSubmit.indexOf("是") > 0 ? 1 : 0;
            obj[i].IsUpload = obj[i].IsUpload.indexOf("是") > 0 ? 1 : 0;
            obj[i].UploadState = obj[i].UploadState.indexOf("check") > 0 ? 1 : 0;
            obj[i].CommitState = obj[i].CommitState.indexOf("on") > 0 ? 1 : 0;
            if (obj[i].IsSubmit == 1 && obj[i].CreateDate == "") scount++;
            if (obj[i].IsUpload == 1 && obj[i].FileUrl == "") ucount++;


        }
        $.ConfirmAjax({
            msg: "注：您确认要进行此操作吗？",
            url: "../../QualificationManage/Retrial/SaveMater?keyValue=" + Id,
            param: { lst: JSON.stringify(obj) },
            loading: "正在保存数据...",
            success: function () {
                location.reload();
            }
        });
    }

    //获取状态
    function GetState(value) {
        var Msg = "";
        switch (value) {
            case 1: Msg = "初审中（初次)";
                break;
            case 2: Msg = "初审中（再次）";
                break;
            case 3: Msg = "初审未通过";
                break;
            case 4: Msg = "递交资料中";
                IsCheck = "T";
                break;
            case 5: Msg = "市局审批中（材料通过）";
                break;
            case 6: Msg = "复审（市局审批通过）";
                break;
            case 7: Msg = "复审通过";
                break;
            case 8: Msg = "复审未通过";
                break;
            case 9: Msg = "客户撤回";
                break;
            case 10: Msg = "材料不通过";
                break;
            default: Msg = "---";
                break;
        }
        return Msg;
    }

    function GetS(data) {
        var s = [];
        for (var i = 0; i < data.length; i++) {
            s.push(Date.parse(data[i].Date.replace(/-/g, "/")));
        }
        debugger;
        max = Math.max.apply(null, s);
        for (var i = 0; i < data.length; i++) {
            if (s[i] == max) {
                var Msg = "";
                if (data[i].Type == 1) {
                    if (data[i].CheckFlag == 0) {
                        Msg = "初审未通过"
                    }
                    else {
                        Msg = "材料提交"
                    }
                    $("#savemater").removeAttr("hidden");
                }
                if (data[i].Type == 2) {
                    if (data[i].CheckFlag == 0) {
                        Msg = "递交材料中"
                        $("#AuditState_CL").removeAttr("hidden");
                        $("#AuditState_SJ").attr("hidden", "hidden");
                        $("#AuditState_SLZX").attr("hidden", "hidden");
                        $("#savemater").removeAttr("hidden");
                        if (State == 10 || State == "10") {
                            $("#AuditState_CL").attr("hidden", "hidden");
                            $("#AuditState_SJ").attr("hidden", "hidden");
                            $("#AuditState_SLZX").attr("hidden", "hidden");
                            $("#savemater").attr("hidden", "hidden");
                            Msg = "材料审核不通过";
                        }
                    }
                    else {
                        Msg = "市局审批中"
                        $("#AuditState_CL").attr("hidden", "hidden");
                        $("#AuditState_SJ").removeAttr("hidden");
                        $("#AuditState_SLZX").attr("hidden", "hidden");
                    }
                }
                if (data[i].Type == 3) {
                    if (data[i].CheckFlag == 0) {
                        Msg = "递交材料中"
                        $("#AuditState_CL").removeAttr("hidden");
                        $("#AuditState_SJ").attr("hidden", "hidden");
                        $("#AuditState_SLZX").attr("hidden", "hidden");
                        $("#savemater").removeAttr("hidden");
                        if (State == 10 || State == "10") {
                            $("#AuditState_CL").attr("hidden", "hidden");
                            $("#AuditState_SJ").attr("hidden", "hidden");
                            $("#AuditState_SLZX").attr("hidden", "hidden");
                            Msg = "材料审核不通过";
                        }

                    }
                    else {
                        Msg = "复审中";
                        $("#AuditState_SLZX").removeAttr("hidden");
                        $("#AuditState_SJ").attr("hidden", "hidden");
                        $("#AuditState_CL").attr("hidden", "hidden");
                    }
                }
                if (data[i].Type == 4) {
                    if (data[i].CheckFlag == 0) {
                        Msg = "复审未通过"
                        $("#AuditState_CL").attr("hidden", "hidden");
                        $("#AuditState_SJ").attr("hidden", "hidden");
                        $("#AuditState_SLZX").attr("hidden", "hidden");

                    }
                    else {
                        Msg = "复审通过";
                        $("#AuditState_CL").attr("hidden", "hidden");
                        $("#AuditState_SJ").attr("hidden", "hidden");
                        $("#AuditState_SLZX").attr("hidden", "hidden");
                    }
                }
                if (State == "9") {
                    Msg = "客户撤回";
                    $("#AuditState_CL").attr("hidden", "hidden");
                    $("#AuditState_SJ").attr("hidden", "hidden");
                    $("#AuditState_SLZX").attr("hidden", "hidden");
                }
                return Msg;
            }
        }


    }
    function GetCategory(s) {
        var Msg = "";
        switch (s) {
            case 1: Msg = "初次申请";
                break;
            case 2: Msg = "再次申请";
                break;
            case 3: Msg = "续租申请";
                break;
            case 4: Msg = "再次续租申请";
                break;
            default: Msg = "---";
                break;
        }
        return Msg;
    }
    function GetGridB(data) {
        var $gridTable = $("#gridTableB");
        $gridTable.jqGrid({
            datatype: "json",
            height: 80,
            autowidth: true,
            unwritten: false,
            colModel: [
              { label: "主键", name: "Id", hidden: true },

              { label: "审核人", name: "CheckMan", index: "CheckMan", width: 300, align: "center", sortable: false },
              { label: "审核时间", name: "CheckDate", index: "CheckDate", width: 300, align: "center", sortable: false },
              {
                  label: "审核结果", name: "CheckFlag", index: "CheckFlag", width: 300, align: "center", sortable: false,
                  formatter: function (cellvalue, options, rowObject) {
                      var Msg = "";
                      if (rowObject.Type == 1) {
                          if (cellvalue == 0) {
                              Msg += "初审未通过"
                          }
                          else {
                              Msg += "初审通过"
                          }
                      }
                      if (rowObject.Type == 2) {
                          if (cellvalue == 0) {
                              Msg += "材料未通过"
                          }
                          else {
                              Msg += "材料通过"
                          }
                      }
                      if (rowObject.Type == 3) {
                          if (cellvalue == 0) {
                              Msg += "市局审批未通过"
                          }
                          else {
                              Msg += "市局审批通过"
                          }
                      }
                      if (rowObject.Type == 4) {
                          if (cellvalue == 0) {
                              Msg += "复审未通过"
                          }
                          else {
                              Msg += "复审通过"

                          }
                      }
                      return Msg;
                  }
              },
              { label: "审核说明", name: "CheckMemo", index: "CheckMemo", width: 600, align: "center", sortable: false },
            ],
            viewrecords: true,
            rowNum: 300,
            sortname: 'CheckDate',
            sortorder: 'asc',
            gridview: true
        });
        var arr = $.grep(data, function (value) {
            return value.Type == 2;
        })
        $gridTable[0].addJSONData(arr);

    }
    function GetGridC(data) {
        var $gridTable = $("#gridTableC");
        $gridTable.jqGrid({
            datatype: "json",
            autowidth: true,
            height: 80,
            unwritten: false,
            colModel: [
              { label: "主键", name: "Id", hidden: true },
              { label: "审核人", name: "CheckMan", index: "CheckMan", width: 300, align: "center", sortable: false },
              { label: "审核时间", name: "CheckDate", index: "CheckDate", width: 300, align: "center", sortable: false },
              {
                  label: "审核结果", name: "CheckFlag", index: "CheckFlag", width: 300, align: "center", sortable: false,
                  formatter: function (cellvalue, options, rowObject) {
                      var Msg = "";
                      if (rowObject.Type == 1) {
                          if (cellvalue == 0) {
                              Msg += "初审未通过"
                          }
                          else {
                              Msg += "初审通过"
                          }
                      }
                      if (rowObject.Type == 2) {
                          if (cellvalue == 0) {
                              Msg += "材料未通过"
                          }
                          else {
                              Msg += "材料通过"
                          }
                      }
                      if (rowObject.Type == 3) {
                          if (cellvalue == 0) {
                              Msg += "市局审批未通过"
                          }
                          else {
                              Msg += "市局审批通过"
                          }
                      }
                      if (rowObject.Type == 4) {
                          if (cellvalue == 0) {
                              Msg += "复审未通过"
                          }
                          else {
                              Msg += "复审通过"

                          }
                      }
                      return Msg;
                  }
              },
              { label: "审核说明", name: "CheckMemo", index: "CheckMemo", width: 650, align: "center", sortable: false },
            ],
            viewrecords: true,
            rowNum: 300,
            sortname: 'CheckDate',
            sortorder: 'asc',
            gridview: true,

        });
        var arr = $.grep(data, function (value) {
            return value.Type == 3;
        })
        $gridTable[0].addJSONData(arr);

    }
    function GetGridD(data) {
        var $gridTable = $("#gridTableD");
        $gridTable.jqGrid({
            datatype: "json",
            autowidth: true,
            unwritten: false,
            height: 80,
            colModel: [
              { label: "主键", name: "Id", hidden: true },

              { label: "审核人", name: "CheckMan", index: "CheckMan", width: 300, align: "center", sortable: false },
              { label: "审核时间", name: "CheckDate", index: "CheckDate", width: 300, align: "center", sortable: false },
              {
                  label: "审核结果", name: "CheckFlag", index: "CheckFlag", width: 300, align: "center", sortable: false,
                  formatter: function (cellvalue, options, rowObject) {
                      var Msg = "";
                      if (rowObject.Type == 1) {
                          if (cellvalue == 0) {
                              Msg += "初审未通过"
                          }
                          else {
                              Msg += "初审通过"
                          }
                      }
                      if (rowObject.Type == 2) {
                          if (cellvalue == 0) {
                              Msg += "材料未通过"
                          }
                          else {
                              Msg += "材料通过"
                          }
                      }
                      if (rowObject.Type == 3) {
                          if (cellvalue == 0) {
                              Msg += "市局审批未通过"
                          }
                          else {
                              Msg += "市局审批通过"
                          }
                      }
                      if (rowObject.Type == 4) {
                          if (cellvalue == 0) {
                              Msg += "复审未通过"
                          }
                          else {
                              Msg += "复审通过"

                          }
                      }
                      return Msg;
                  }
              },
              { label: "审核说明", name: "CheckMemo", index: "CheckMemo", width: 650, align: "center", sortable: false },
            ],
            viewrecords: true,
            rowNum: 300,
            sortname: 'CheckDate',
            sortorder: 'asc',
            gridview: true,

        });
        var arr = $.grep(data, function (value) {
            return value.Type == 4;
        })
        $gridTable[0].addJSONData(arr);

    }
</script>


<div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
    <div class="ui-layout-west">
        <div class="west-Panel">
            <div class="profile-nav">
                <ul style="padding-top: 20px;">
                    <li class="active" onclick="profileSwitch('BillContent')">单据内容</li>
                    <li onclick="profileSwitch('TrialRecord')">审核记录</li>
                    <li onclick="profileSwitch('TrialLog')">单据日志</li>
                </ul>
            </div>
        </div>
    </div>
    <div class="ui-layout-center">
        <div class="center-Panel">
            <div class="profile-content" style="background: #fff; ">
                <div id="BillContent">
                    <table class="form" id="BillInfo" style="margin-top: 20px;">
                        <tr>
                            <td class="formTitle">单据编号：</td>
                            <td class="formValue"><a href="#" onclick="Detail()" id="Code" style="color:blue; font-size:18px; text-decoration:underline;">XXXXX</a></td>
                            <td class="formTitle">创建时间：</td>
                            <td class="formValue"><input class="form-control" style="border:none;" readonly id="CreateDate" type="text" /></td>
                            <td class="formTitle">初审通过时间：</td>
                            <td class="formValue"><input class="form-control" style="border:none;" readonly id="FirstCheckDate" type="text" /></td>
                            <td class="formTitle">审批人：</td>
                            <td class="formValue"><input class="form-control" style="border:none;" readonly id="FirstCheckMan" type="text" /></td>
                        </tr>
                        <tr>
                            <td class="formTitle">复审状态：</td>
                            <td class="formValue">
                                <span style="color: red; font-size: 18px; " id="State"></span>
                            </td>
                            <td>家庭类型：</td>
                            <td class="formValue">
                                <span style="color:red;font-size:18px;" id="FamilyType"></span>
                            </td>
                            <td>申请类型：</td>
                            <td class="formValue">
                                <span style="color:red;font-size:18px;" id="SignType"></span>
                            </td>
                            <td class="formTitle">业务类型：</td>
                            <td class="formValue">
                                <span style="color:red;font-size:18px;" id="Category"></span>
                            </td>
                        </tr>
                        <tr>
                            <td class="formTitle">姓名：</td>
                            <td class="formValue">
                                <span style=" font-size: 18px; " id="Name"></span>
                            </td>
                            <td>联系方式：</td>
                            <td class="formValue">
                                <span style=" font-size: 18px; " id="Phone"></span>
                            </td>
                            <td class="formTitle">身份证号码：</td>
                            <td class="formValue">
                                <span style="font-size:18px;" id="IDCard"></span>
                            </td>
                            <td class="formTitle AuditTimes" hidden>审批时长：</td>
                            <td class="formValue AuditTimes" hidden>
                                <span style="font-size:18px;" id="Times"></span>
                            </td>
                        </tr>
                        <tr style=" height: 20px; border-bottom: 1px dashed #cecece;"><td colspan="8"></td> </tr>
                        <tr style="height:10px;"></tr>
                        <tr>
                            <td><h4>资料收集</h4></td>
                            <td></td>
                            <td>第<span style="color:red;font-size:24px;" id="SubmitCount"></span>次提交</td>
                            <td></td>
                            <td class="formTitle">资料提交日期：</td>
                            <td class="formValue"><input class="form-control" style="border:none;" readonly id="Date" type="text" /></td>
                        </tr>
                    </table>
                    <br />

                    <div class="center-Panel">
                        <div class="gridPanel">
                            <table id="gridTable1"></table>
                        </div>
                    </div>
                    <div style="height:10px;width:1px;"></div>
                    <table class="form" id="CLTJ" class="form" style="background-color: #F5F5F5;">
                        <tr>
                            <td class="formTitle"><h4 id="SJBH">材料审核</h4></td>
                            <td colspan="7"></td>
                            <td id="savemater" hidden><a id="lr-savemater" class="btn btn-success btn-xs" style="width: 50%; height: 25px; line-height: 20px; " onclick="SaveMater(); ">保存材料</a></td>
                        </tr>
                        <tr>
                            <td colspan="9">
                                <div class="center-Panel">
                                    <div class="gridPanel">
                                        <table id="gridTableB"></table>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <tr id="AuditState_CL">
                            <td class="formTitle">受理编号：</td>
                            <td class="formValue"><input id="CityBurceauCode" class="form-control" type="text" isvalid="yes" checkexpession="IsScript" /></td>
                            <td class="formTitle" style="text-align:right;">审批意见：</td>
                            <td class="formValue" colspan="4"><input id="CL_Memo" class="form-control" type="text" isvalid="yes" checkexpession="IsScript" /></td>
                            <td class="formValue">
                                <a id="lr-materyes" class="btn btn-success btn-xs" style="width:80%;height:28px;line-height:28px; margin-left:30px;" onclick="SubmitFile(1); ">同意</a>
                            </td>
                            <td class="formValue">
                                <a id="lr-materno" class="btn btn-danger btn-xs" style="width: 80%; height: 28px; line-height: 28px;" onclick="SubmitFile(0); ">不同意</a>
                            </td>
                        </tr>
                        <tr style=" height: 20px; border-bottom: 1px dashed #cecece;"><td colspan="9"></td> </tr>
                    </table>
                    <table id="SJSP" class="form" style="background-color: #F5F5F5;">
                        <tr>
                            <td class="formTitle"><h4 id="SJBH">市局审批</h4></td>
                        </tr>
                        <tr>
                            <td colspan="9">
                                <div class="center-Panel">
                                    <div class="gridPanel">
                                        <table id="gridTableC"></table>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <tr id="AuditState_SJ">
                            <td class="formTitle" style="text-align:right;">审批意见：</td>
                            <td class="formValue" colspan="6"><input id="SJ_Memo" class="form-control" type="text" isvalid="yes" checkexpession="IsScript" /></td>
                            <td class="formValue">
                                <a id="lr-cityyes" class="btn btn-success btn-xs" style="width: 80%; height: 28px; line-height: 28px; margin-left: 30px;" onclick="Submit(1); ">同意</a>
                            </td>
                            <td class="formValue">
                                <a id="lr-cityno" class="btn btn-danger btn-xs" style="width: 80%; height: 28px; line-height: 28px;" onclick="Submit(2); ">不同意</a>
                            </td>
                        </tr>
                        <tr style=" height: 20px; border-bottom: 1px dashed #cecece;"><td colspan="9"></td> </tr>
                    </table>
                    <table id="SLZXSP" class="form" style="background-color: #F5F5F5;">
                        <tr>
                            <td class="formTitle"><h4 id="SJBH">受理中心审批</h4></td>
                        </tr>
                        <tr>
                            <td colspan="9">
                                <div class="center-Panel">
                                    <div class="gridPanel">
                                        <table id="gridTableD"></table>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <tr id="AuditState_SLZX">
                            <td class="formTitle" style="text-align:right;">审批意见：</td>
                            <td class="formValue" colspan="6"><input id="SLZX_Memo" class="form-control" type="text" isvalid="yes" checkexpession="IsScript" /></td>
                            <td class="formValue">
                                <a id="lr-centeryes" class="btn btn-success btn-xs" style="width: 80%;; height: 28px; line-height: 28px; margin-left: 30px;" onclick="Submit(3); ">同意</a>
                            </td>
                            <td class="formValue">
                                <a id="lr-centerno" class="btn btn-danger btn-xs" style="width: 80%; height: 28px; line-height: 28px;" onclick="Submit(4); ">不同意</a>
                            </td>
                        </tr>
                        <tr style=" height: 20px;"><td colspan="9"></td> </tr>
                    </table>
                </div>
                <div id="TrialRecord" style="display: none;">
                    <div class="title">
                        审核记录
                    </div>

                    <div class="gridPanel">
                        <table id="gridTable2"></table>
                    </div>
                </div>
                <div id="TrialLog" style="display: none;">
                    <div class="title">
                        操作日志
                    </div>

                    <div class="gridPanel">
                        <table id="gridTable6"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



